<?php
/**
 * Created by PhpStorm.
 * User: River
 * Email: river0428@gmail.com
 * Date: 2018/11/13
 * Time: 下午1:35
 */

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Banner extends Model
{
    protected $table = 'banner';

    protected $guarded = [];

    public $appends = [
        'name'
    ];

    public function image()
    {
        return $this->belongsTo(Attachments::class, 'image_id', 'id');
    }

    public function getNameAttribute()
    {
        switch ($this->redirect_to) {
            case 'redirect://oilcard:8888/station' :
                return '加油站';
                break;
            case 'redirect://oilcard:8888/recharge' :
                return '充值';
                break;
            case 'redirect://oilcard:8888/question' :
                return '常见问题';
                break;
            case 'redirect://oilcard:8888/wap?url=http%3A%2F%2Fyk.123dailu.com%2Fapp%2Ffirst' :
                return '新人专享';
                break;
            case 'redirect://oilcard:8888/wap?url=http%3A%2F%2Fyk.123dailu.com%2Fapp%2Fsafe' :
                return '安全保障';
                break;
            case 'redirect://oilcard:8888/wap?url=http%3A%2F%2Fyk.123dailu.com%2Fapp%2Ffind' :
                return '发现';
                break;
            case 'redirect://oilcard:8888/wap?url=http%3A%2F%2Fyk.123dailu.com%2Fapp%2Finstruction' :
                return '充值说明';
                break;
            default :
                break;
        }
    }

}